import searchIndexHtml from '../views/search.art'
import searchModels from  '../models/movie'
import searchlistHtml from '../views/search-list.art'



class search{
    constructor(){
  this.render()
    }

renderer(list){
let html=searchlistHtml({
  list
})
$('.list').html(html)
}

    render(){
      let that=this
    let html=searchIndexHtml()
    $('#search-root').html(html)

  $('.search input').on('input',function(){
    let val=this.value.trim();
    if(val){
   that.getDate(val)
  }
  })
     
    }

  async  getDate(kw){
      let result=await searchModels.search(`${kw}`)
     this.renderer(result.cinemas.list)
    }

}
new search()